<?php
class Feedback_model extends CI_Model {
    public function __construct() {
        parent::__construct();
        $this->load->database();
    }
    
    public function insert($feedback) {
        $this->db->insert('feedback', $feedback);
        $res = $this->db->affected_rows();
        if ($res > 0) {
            return TRUE;
        } else {
            return FALSE;
        }
    }
    
    public function get() {
        $this->db->where('fb_reply', FALSE);
        $query = $this->db->get('feedback');
        
        if ($query->num_rows() > 0) {
            return $query->result_array();
        } else {
            return NULL;
        }
    }
    
    public function handle($fb_id) {
        $this->db->where('fb_id', $fb_id);
        $this->db->set('fb_reply', true);
        $this->db->update('feedback');
        return $this->db->affected_rows();
    }
}
?>